home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / lfnsrt14.zip / LFNSORT.TXT < prev   
Text File  |  1996-09-15  |  22KB  |  485 lines

  1. LFNSORT v 1.4 - Sorts DOS/Win95 directories
  2.  
  3. Copyright (c) 1995,1996 D.J. Murdoch.
  4.  
  5. 0. Contents of this file
  6.  
  7.    1. Syntax
  8.    2. Description
  9.    3. Details
  10.    4. Memory Limitations
  11.    5. Safety
  12.    6. License
  13.    7. Release History
  14.    8. Known bugs
  15.    9. Acknowledgments
  16.  
  17. 1. Syntax:
  18.  
  19.       LFNSORT sortkeys [dirname] [options]
  20.  
  21.         will sort the directory records on disk according to the
  22.         specified sort keys.
  23.  
  24.       Keys:
  25.         N - full filename
  26.         E - extension
  27.         D - last modification date
  28.         T - last modification time
  29.         C - creation date/time
  30.         A - last access date/time
  31.         S - size
  32.  
  33.         Place a "-" minus sign in front of a key to sort in descending
  34.         order instead of ascending order.  Keys can be combined, e.g.
  35.         "-DN" for "sorted by descending modification date, and by
  36.         ascending name within date".  Use "-" by itself as a placeholder
  37.         if you want no sort key.
  38.  
  39.       Options:
  40.         /8       base sort order on 8.3 version of names instead of long
  41.                  names
  42.         /C       case sensitive sort - ascii sort order
  43.         /D       mix directories in with files
  44.         /Debug file  write debug information to file
  45.         /F filename  read forced sort order from file (see below for
  46.                  syntax and examples
  47.         /K       keep erased entries, and keep directory at original
  48.                  size, even if not all space is used
  49.         /NW      no write - changes won't be saved to disk
  50.         /S       sort subdirectories recursively
  51.         /System  don't sort system files first in the root dir
  52.         /V       verbose mode; list all directories and filenames after
  53.                  sorting
  54.  
  55.       Examples:
  56.  
  57.         To sort every subdirectory on drive C: by file extension then
  58.         filename:
  59.  
  60.           LFNSORT en c:\ /s
  61.  
  62.         To sort every directory on drive C: so that most recently
  63.         accessed files come first:
  64.  
  65.           LFNSORT -a-d-t c:\ /s
  66.  
  67.         (The "-d-t" is necessary because not all directory records
  68.         include an access time; older ones and ones created in DOS mode
  69.         will only have a modification time.)
  70.  
  71. 2. Description:
  72.  
  73.         The original Norton Utilities had a program called DS which
  74.         could sort your DOS directories according to your preferences.
  75.         Later versions added a graphical interface so you could manually
  76.         move files around.
  77.  
  78.         When Win95 came out with the VFAT long filenames, DS stopped
  79.         working.  It hadn't been written to handle the new directory
  80.         records.  Symantec (the current owners of the Norton Utilities)
  81.         haven't produced a new version of DS as far as I know, so when
  82.         Jacques Bensimon suggested that a minor modification to my
  83.         long filename backup utility DOSLFNBK could do directory sorts,
  84.         I decided that I wanted DS badly enough to write it myself.
  85.         There is already at least one freeware/shareware utility called
  86.         DIRSORT, so I called mine LFNSORT.
  87.  
  88. 3. Details:
  89.  
  90.       Disk locking:
  91.  
  92.         LFNSORT works on the disk drive at a pretty low level.  To be
  93.         allowed this access, it requests exclusive access to the drive
  94.         from Windows.  If another program has already requested
  95.         exclusive access, LFNSORT will exit and do nothing.  While
  96.         LFNSORT is running, other programs will not be allowed to write
  97.         to the disk or to create new files.  This may confuse them; it's
  98.         probably best not to attempt any other disk activity in the
  99.         middle of an LFNSORT run.  (LFNSORT has been written according to
  100.         Microsoft's instructions to work without damaging your disk even
  101.         if another program attempts access, but the other program might
  102.         not be.)
  103.  
  104.         LFNSORT handles the disk locking itself.  In fact, if you use
  105.         the LOCK command to lock the drive, LFNSORT will be unable to
  106.         obtain a lock, and will not run.
  107.  
  108.         If you run LFNSORT under DOS, or in a version of Windows that
  109.         doesn't support drive locking, it will still run.  If it detects
  110.         Windows it will warn you that running in a multitasker without
  111.         protecting the disk from changes is dangerous, and will only
  112.         go ahead if you confirm you really mean it.  If it doesn't detect
  113.         Windows, it will assume that it is safe to go ahead --- so if
  114.         you're using another multitasker like Desqview, use it with
  115.         extreme care!
  116.  
  117.       Forcing a particular order:
  118.  
  119.         The /F option takes a plain ascii file as an argument.  This
  120.         file should have the following format:
  121.  
  122.            \directory1
  123.            firstfile
  124.            secondfile
  125.            thirdfile
  126.  
  127.            \directory2
  128.            afile
  129.            bfile
  130.            cfile
  131.  
  132.         Specifically:  any line with a backslash "\" in it is taken as a
  133.         directory name, any other non-blank line is taken as a filename.
  134.  
  135.         These will force the files in directory1 and directory2 into the
  136.         order given.  If a file isn't listed, it will normally appear
  137.         *after* all the listed files.  However, you can override this by
  138.         putting a "*" entry in place of a file; then all unlisted files
  139.         will be placed there.  For example,
  140.  
  141.           \directory
  142.           firstfile
  143.           *
  144.           lastfile
  145.  
  146.         will guarantee the placement of those two files, but sort
  147.         everything else according to the specified sort keys.  (Hint:
  148.         if you want to use the file to specify part of the order but
  149.         make no other changes, use "-" as a sort key.)
  150.  
  151.         The order in which the directory sections appear in this file is
  152.         ignored. If you want directories in a particular order, list
  153.         them in a section for their parent directory. If you don't
  154.         specify any directory name, the ordering is used as a default
  155.         for unlisted directories. For example, to put README.1ST
  156.         files first in every directory where they exist, put a single
  157.         line containing "README.1ST" into a file called FORCED.LST, and
  158.         run
  159.  
  160.           LFNSORT - c:\ /f forced.lst
  161.  
  162.         File and directory names in this file may normally be either 8.3
  163.         aliases or long filenames, but if you're running outside Windows
  164.         where there is no long filename support, you *must* use the 8.3
  165.         alias.
  166.  
  167.         If you want to force the file order for a large collection of
  168.         directories, you can use the /V option to create a preliminary
  169.         version of the forcing file.  For example,
  170.  
  171.           LFNSORT - c:\ /D/System/NW/S/V >new.lst
  172.  
  173.         will write a list of the files in their current order
  174.         into the "new.lst" file.  The - specifies no sorting, and the
  175.         /D and /System options turn off the default actions for
  176.         directories and system files.
  177.  
  178.       Moving system files:
  179.  
  180.         Normally the root directory of your boot drive has IO.SYS first,
  181.         and MSDOS.SYS in the second place.  As long as these are left
  182.         with the System and Hidden attributes set, LFNSORT won't move
  183.         them.  However, if you accidentally move them and want to
  184.         restore them to the start of the directory (because some
  185.         versions of DOS won't boot if they get moved):
  186.  
  187.         Put these two lines in a file called FORCED.LST:
  188.  
  189.           IO.SYS
  190.           MSDOS.SYS
  191.  
  192.         and run
  193.  
  194.           LFNSORT - c:\ /F forced.lst /System /D
  195.  
  196.       Volume labels:
  197.  
  198.         Pre-7.0 versions of DOS can be confused by long filename
  199.         records, which look to them like volume labels.  This can be
  200.         fixed by putting the volume label before any long filenames in
  201.         the directory, but the Win95 LABEL command doesn't do this.
  202.         LFNSORT fixes this, unless you use the /System option, in which
  203.         case the volume label will be sorted like a file record.  Don't
  204.         put the volume label ahead of your boot files, if you want your
  205.         disk to be bootable.
  206.  
  207.         Example:  If you want to put the volume label "BIG DRIVE" just
  208.         after IO.SYS and MSDOS.SYS, set FORCED.LST to
  209.  
  210.           IO.SYS
  211.           MSDOS.SYS
  212.           BIG DRIVE
  213.  
  214.         and run
  215.  
  216.           LFNSORT - c:\ /F forced.lst /System /D
  217.  
  218.       Keeping original size:
  219.  
  220.         Normally when LFNSORT sorts a directory, it removes erased file
  221.         entries, and shrinks the disk allocation for the directory as
  222.         much as possible.  If you use the /K option, erased file entries
  223.         will moved to the end of the directory (but will not otherwise
  224.         be sorted), and the disk allocation of the subdirectory will be
  225.         left unchanged.
  226.  
  227.       Exact sort rules:
  228.  
  229.         What LFNSORT does when sorting a directory is to compare all
  230.         files, applying the following rules in order until it can tell
  231.         which of a pair of files should come first:
  232.  
  233.           1.  "." and ".." are always left in place.
  234.           2.  If the /K option is used, then erased file entries are put
  235.               last in the directory, in their original order.  With no
  236.               /K, the erased file entries will be deleted.
  237.           3.  Unless you override it with the /System option, files
  238.               in the root directory with the System attribute will be
  239.               moved ahead of other files but will otherwise not be sorted.
  240.               The volume label entry will be moved just after them.
  241.           4.  If you haven't used the /D option, then subdirectories
  242.               are placed before files.
  243.           5.  If you have used a /F file to force a sort order, and the
  244.               current directory is listed there, then it is used to
  245.               specify the order.  If the current directory isn't listed
  246.               there but files are listed with no directory name, then
  247.               that order is used.  Any file which isn't listed is put in
  248.               the place of "*" in the list, which defaults to last.
  249.           6.  The comparison rules given by the sort key are applied
  250.               in order from left to right.
  251.           7.  If after all those comparisons LFNSORT can't tell which of
  252.               two files should come first, then they're left in the
  253.               original order (i.e. LFNSORT performs a "stable" sort.)
  254.  
  255.       Running in DOS or DOS mode:
  256.  
  257.         LFNSORT should be able to run in pre-Win95 versions of DOS, or
  258.         in the DOS mode of Win95 (the one you get if you "Restart
  259.         computer in MS-DOS mode" or choose console mode from the initial
  260.         boot menu).  The main limitation is that long filenames aren't
  261.         supported on the command line or in the forced order file.
  262.         However, the (invisible) long filename records will still be
  263.         sorted, and the /V option can be used to print the long names of
  264.         files.  Directory names will be printed in the 8.3 form.
  265.  
  266.       Erased file records:
  267.  
  268.         By default, LFNSORT deletes any erased file records that are
  269.         left in the directory.  This helps to speed up disk access, but
  270.         it means that some file undeletion programs (the ones that don't
  271.         keep their own records of deleted files) won't be able to
  272.         undelete files after a LFNSORT run.  LFNSORT will also by
  273.         default shrink the disk space used by a directory.  Use the /K
  274.         option to keep erased files and to suppress shrinking of the
  275.         directory.
  276.  
  277.         When both the /K "keep" and /V "verbose" options are used,
  278.         erased file entries will be printed with the first letter of the
  279.         short name changed to σ (ASCII 229), just as they are stored on
  280.         the disk.  Erased long filenames will not be printed.
  281.  
  282.       Errors on your disk:
  283.  
  284.         When you run pre-Win95 versions of DOS and work with directories
  285.         containing long filenames, it is very easy to mess them up.
  286.         Some of these errors may cause LFNSORT to act in unpredictable
  287.         ways.  I recommend always running SCANDISK after working with
  288.         files in DOS mode.
  289.  
  290.         LFNSORT will detect the most common type of these errors,
  291.         "orphaned long filename records".  These occur when you rename a
  292.         file in an old DOS, and the LFN part of the record isn't updated
  293.         properly, or when you delete a file in old DOS and the LFN
  294.         doesn't get deleted.  If it finds these orphans, it will print a
  295.         warning message, and give you the option of continuing.  If you
  296.         choose to continue, the orphaned records will be deleted.
  297.         Don't do this if you'd like to use some other program to recover
  298.         them; after LFNSORT sorts the directory, they'll be gone
  299.         forever.
  300.  
  301.  
  302. 4. Memory Limitations:
  303.  
  304.         Once it has exclusive access to the disk, LFNSORT reads entire
  305.         subdirectories into memory all at once.  Because this version is
  306.         a DOS real mode program, that limits the size of directory that
  307.         it can sort.  It needs enough space to store two copies of the
  308.         whole directory record in memory, which means it will refuse to
  309.         sort directories with more than about 6000 short filenames.
  310.         Long filenames take up more space, and the limit will be lower.
  311.  
  312.         If you have a directory that is too large to sort, LFNSORT will
  313.         just leave it as is on the disk.  Your only choice then is to
  314.         manually move enough files out of the directory so that LFNSORT
  315.         can run, and then move the files back afterwards.
  316.  
  317. 5. Safety:
  318.  
  319.         LFNSORT works with your disk at a level below the file system,
  320.         so if things go wrong while rewriting a directory, it's
  321.         conceivable that you could lose whole files or directories.
  322.         I've tried to make it as safe as I can, but you should follow
  323.         some simple precautions:
  324.  
  325.           - If you aren't sure of the integrity of your file system, run
  326.           Scandisk before LFNSORT and get it to fix any errors.  In
  327.           particular, if you've run other low level software (e.g. a
  328.           defragger or DOS-based directory sorter) that may have messed
  329.           up the LFNs, run Scandisk first.
  330.  
  331.           - Don't turn off or reboot your PC in the middle of an LFNSORT
  332.           run.  If there's a power failure or (horrors!) a bug in
  333.           LFNSORT forces you to reboot, then Scandisk should be able to
  334.           repair most of the damage, but you may have to manually rename
  335.           some files.
  336.  
  337.           - If you hit Ctrl-Break or Ctrl-C during an LFNSORT run,
  338.           it shouldn't do any damage other than giving you only a
  339.           partial sort.
  340.  
  341.           - LFNSORT was written for version 4.00.950 of Windows 95 (the
  342.           August 1995 release).  It hasn't been tested on the earlier
  343.           beta test versions or on any later release than the 4.00.950a
  344.           maintenance fix pack.  If the VFAT file structure isn't what
  345.           LFNSORT is written for, it could do some real damage.
  346.  
  347.           In particular, LFNSORT will definitely not work on FAT32, and
  348.           if everything works, it will refuse to run there --- but this
  349.           has never been tested since at the time of this writing FAT32
  350.           is still in beta testing.
  351.  
  352.           - There may be special conditions on your system that LFNSORT
  353.           won't be able to handle.  If you can, try it out first when
  354.           you've got a good backup to make sure it works.  If it
  355.           doesn't, *please* send me details, and I'll attempt to fix it.
  356.  
  357. 6. License:
  358.  
  359.         LFNSORT is shareware, *not* public domain software. You may use
  360.         it at no charge for an evaluation period of 30 days only.
  361.         You are free to distribute unmodified copies of the complete
  362.         LFNSORT package, provided your total charge is no more than $1.
  363.         The total cost of a compilation (e.g. a CD ROM) including
  364.         LFNSORT must be no more than $1 per package in the compilation.
  365.  
  366.         To continue to use LFNSORT beyond the 30 day evaluation period,
  367.         you must register it.  There are three possible registration
  368.         levels available:
  369.  
  370.           $10 simple registration + $5 handling charge
  371.  
  372.         This registration fee gives you a license to use one copy of
  373.         LFNSORT indefinitely.  If you include an email address I will
  374.         notify you of new versions and how to obtain them yourself. I'll
  375.         also attempt to answer emailed questions about LFNSORT from
  376.         registered users. Payment may be made in Canadian or US dollars
  377.         (at par), or the UKP equivalent of $15 US.  NOTE:  See below for
  378.         how to avoid the handling charge.
  379.  
  380.           $20 upgrade registration + $5 handling charge
  381.  
  382.         This registration fee also entitles you to use LFNSORT
  383.         indefinitely.  In addition to the license to use it, I will mail
  384.         you a diskette containing the latest version, together with a
  385.         collection of other freeware and (unregistered) shareware
  386.         programs that I have written (including DOSLFNBK).  If you send
  387.         an email address I will notify you of updates, and send one free
  388.         update by email if you request it.  Payment may be made in
  389.         Canadian or US dollars (at par), or the GBP (Sterling)
  390.         equivalent of $25 US.
  391.  
  392.           $45 source code registration + $5 handling charge
  393.  
  394.         LFNSORT was written in Borland Pascal 7.01, using the excellent
  395.         Object Professional library from TurboPower Software.  In
  396.         addition to the benefits of the upgrade registration, the source
  397.         code registration gives you the LFNSORT source code (including
  398.         an object-oriented low-level disk access unit, access to the new
  399.         Win95 DOS API functions, and a huge memory support unit, but not
  400.         OPro).  Payment may be made in Canadian or US dollars (at par),
  401.         or the GBP equivalent of $50 US.
  402.  
  403.         Any of the registrations can be done by sending a cheque or
  404.         money order to:
  405.  
  406.          Duncan Murdoch
  407.          337 Willingdon Ave.
  408.          Kingston, Ontario, Canada.
  409.          K7L 4J3
  410.  
  411.         NOTE 1:  If you send a $10 simple registration order directly to
  412.         me at this address, I will waive the handling fee.  Send a
  413.         cheque or money order for $10 in Canadian or US dollars, or the
  414.         UKP equivalent of $10 US.
  415.  
  416.         NOTE 2:  I will be going overseas from August 1996 to June 1997.
  417.         During this time I will still fill orders, but there are almost
  418.         certain to be delays.
  419.  
  420.         You can also register or order source code from the Public
  421.         (software) Library (PsL) using MC, Visa, AmEx, or Discover card:
  422.           - by calling 800-242-4775 (US only)
  423.           - by calling 713-524-6394
  424.           - by faxing your order to 713-524-6398
  425.           - by sending your order by Compuserve to 71355,470
  426.           - by sending your order by Internet to
  427.             71355.470@compuserve.com
  428.         PsL only accepts payment in US dollars. Please give PsL your
  429.         name exactly as it appears on the card, and tell them your
  430.         card's expiry date. LFNSORT is PsL product #14528.
  431.  
  432.         The PsL numbers are for ordering only.  I *cannot* be reached at
  433.         the PsL numbers.  To contact me for information about dealer
  434.         pricing, volume discounts, site licensing, the status of
  435.         shipment of the product, the latest version number or for
  436.         technical information, write to me at the address above or the
  437.         email address below.  I'd especially like to hear bug reports
  438.         and suggestions for improvements.
  439.  
  440.          Internet:   dmurdoch@mast.queensu.ca
  441.  
  442. 7. Release history:
  443.  
  444.         0.0 - first alpha test version
  445.         0.1 - second test version.  Bugs fixed; parameter parsing logic
  446.               rationalized; /NW and /V options added; DOS support added
  447.         0.2 - fixed bug with writing to a directory being sorted,
  448.               formatting /V
  449.         0.3 - worked around Stacker incompatibility
  450.         1.0 - first public release, same as 0.3 except for removal of
  451.               debugging code
  452.         1.1 - added special handling of volume labels
  453.         1.2 - dropped use of obsolete DOS service 1Ch,
  454.               minor cosmetic changes, improved memory management,
  455.               allowed use of SUBST, added check for existence of initial
  456.               directory, stopped treating System directories as special,
  457.               fixed display of volume label
  458.         1.3 - fixed bug which messed up disk if volume label matched
  459.               directory name; made it a tiny bit faster, and slightly
  460.               less vulnerable to errors on the disk; added /K option to
  461.               keep erased entries; added default shrinking of disk
  462.               allocation.
  463.         1.4 - Fixed minor empty root dir bug, /k bug, added integrity
  464.               check of directory before sorting
  465.  
  466. 8. Known bugs
  467.  
  468.         When run in Win95 in a DOS window, the window sometimes switches
  469.         to full screen when LFNSORT locks a disk drive.  On some
  470.         systems, this results in junk on the screen.
  471.  
  472.         Very large directories won't be sorted.
  473.  
  474.         International character sets aren't sorted properly.
  475.  
  476. 9. Acknowledgments
  477.  
  478.         LFNSORT wouldn't have been written without the enthusiastic
  479.         encouragement of Jacques Bensimon.  It relies heavily on the
  480.         source code to DOSLFNBK, which was written based on the
  481.         information in Robert Hummel's article on Win95 long filenames
  482.         in the June/July 1995 issue of PC Techniques Magazine.  Thanks
  483.         are also due to the DOSLFNBK and LFNSORT beta testers, several
  484.         of whom were put to considerable inconvenience.
  485.